<!-- 系统自动生成 Date:2021-10-21 09:46 -->
<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="主子表/CRUD" bodyClass="gray-bg animated fadeInRight" isAnimation=false libs=["table","zTree"]/>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <@f.form id="testData-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <label> ${i18n("员工编号")}：</label>
                            <@f.input placeholder="员工编号" name="code"/>
                        </li>
                        <li>
                            <label> ${i18n("姓名")}：</label>
                            <@f.input placeholder="姓名" name="name"/>
                        </li>
                        <li>
                            <label> ${i18n("邮箱")}：</label>
                            <@f.input placeholder="邮箱" name="email"/>
                        </li>
                        <li>
                            <label> ${i18n("电话")}：</label>
                            <@f.input placeholder="电话" name="phone"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;&nbsp;<@ctx.i18n text = "查询"/></a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;<@ctx.i18n text = "重置"/></a>
                            <a class="btn btn-default btn-rounded btn-sm" data-toggle="formMore"><i class="fa fa-angle-double-down"></i>&nbsp;<@ctx.i18n text = "更多"/></a>
                        </li>
                    </ul>
                </div>
                <div class="select-list-more">
                    <ul>
                        <li>
                            <label> ${i18n("年龄")}：</label>
                            <@f.input placeholder="年龄" name="age"/>
                        </li>
                        <li class="select-time">
                            <label> ${i18n("入职日期")}： </label>
                            <input type="text" class="form-control time-input" placeholder="" name="JoinDate"/>
                        </li>
                        <li class="select-time">
                            <label> ${i18n("离职日期")}： </label>
                            <input type="text" class="form-control time-input" placeholder="" name="LeaveDate"/>
                        </li>
                    </ul>
                </div>
            </@f.form>
        </div>
        <@table id="bootstrap-table">
            <@shiro.hasPermission name="demo:testData:add">
                <a class="btn btn-success" onclick="opt.operate.addTab()"><i class="fa fa-plus"></i>&nbsp;${i18n("新增")}</a>
            </@shiro.hasPermission>
            <@shiro.hasPermission name="demo:testData:edit">
                <a class="btn btn-primary single disabled" onclick="opt.operate.editTab()"><i class="fa fa-pencil-square-o"></i>&nbsp;${i18n("修改")}</a>
            </@shiro.hasPermission>
            <@shiro.hasPermission name="demo:testData:del">
                <a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()"><i class="fa fa-remove"></i> ${i18n("删除")}</a>
            </@shiro.hasPermission>
        </@table>
    </div>
</div>
<@footer>
<script type="text/javascript">
    var editFlag = "${permission.hasPermi("demo:testData:edit")}";
    var listFlag = "${permission.hasPermi("demo:testData:add")}";
    var delFlag = "${permission.hasPermi("demo:testData:del")}";
    var visible = ${permission.isPermitteds("demo:testData:edit,demo:testData:del,demo:testData:add")?string('true', 'false')};
    var sexDatas = ${dict.getDictListJson('sys_user_sex')};
    var prefix = baseURL + "demo/testData";

    $(function() {
        var options = {
            url: prefix + "/list",
            addUrl: prefix + "/add",
            editUrl: prefix + "/edit/{id}",
            delUrl: prefix + "/del",
            modalName: "${i18n("主子表/CRUD")}",
            uniqueId:  'id',/* 唯一ID */
            showPageGo: true,/* 分页设置 */
            pageSize: 10,/* 分页设置 */
            pageList: [10, 30, 50],/* 分页设置 */
            detailView: true,
            onExpandRow : function(index, row, $detail) {
                initChildTable(index, row, $detail);
            },
            columns:[
                {title: $.i18n.text("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }}
                ,{field : 'id',title : '${i18n("id")}',visible: false}
                ,{field : 'code',title : '${i18n("员工编号")}'}
                ,{field : 'name',title : '${i18n("姓名")}'}
                ,{field : 'email',title : '${i18n("邮箱")}'}
                ,{field : 'avatar',title : '${i18n("头像")}',formatter: function(value, row, index) {
                     return $.table.imageView(baseURL+'sys/comm/fileAvatarView?filePath=' +value );
                }}
                ,{field : 'phone',title : '${i18n("电话")}'}
                ,{field : 'sex',title : '${i18n("性别")}',formatter: function(value, row, index) {
                    return opt.common.selectDictLabels(sexDatas, value);
                }}
                ,{field : 'age',title : '${i18n("年龄")}'}
                ,{field : 'joinDate',title : '${i18n("入职日期")}'}
                ,{field : 'leaveDate',title : '${i18n("离职日期")}'}
                ,{field : 'company.name',title : '${i18n("归属公司")}' }
                ,{field : 'organization.name',title : '${i18n("归属部门")}' }
                ,{title:"${i18n("操作")}",align: 'center',visible:visible,class:'action',formatter: function(value, row, index) {
                    var actions = [];
                    actions.push('<a class="' + editFlag + '" href="javascript:void(0)" title="${i18n("编辑")}" onclick="opt.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i></a> ');
                    actions.push('<a class="' + delFlag + '" href="javascript:void(0)" title="${i18n("删除")}" onclick="opt.operate.del(\'' + row.id + '\')"><i class="fa fa-trash-o"></i></a> ');
                    return actions.join('');
                }}
            ]
        };
        $.table.init(options);
    });

    function initChildTable(index, row, $detail) {
        $detail.html('<table id="child_'+index+'" style="table-layout:fixed"></table>').find('table');
        var tableId = "child_"+index;
        $("#" + tableId).bootstrapTable({
            url: prefix + "/child/list",
            method: 'post',
            sidePagination: "server",
            pagination: true,
            pageSize: 10,
            pageList: [10, 15, 20],
            contentType: "application/x-www-form-urlencoded",
            queryParams : function(params) {
                var curParams = {
                /* 传递参数查询参数 */
                __limit: params.limit,
                __page: params.offset / params.limit + 1,
                searchValue: params.search,
                testId: row.id,
                __sidx: params.sort,
                __order: params.order
                };
                return curParams;
            },
            columns: [
                {title: $.i18n.text("序号"), width: 50, align: "center", formatter: function (value, row, index) {
                    return $.table.serialNumber(index,tableId);
                }}
                ,{field : 'id',title : '${i18n("注解")}',visible: false}
                ,{field : 'workCompany',align: "center",title : '${i18n("工作公司")}'}
                ,{field : 'startTime',align: "center",title : '${i18n("起始时间")}'}
                ,{field : 'endTime',align: "center",title : '${i18n("辞职时间")}'}
                ,{field : 'jobs',align: "center",title : '${i18n("在职岗位")}'}
            ]
        });
    };
</script>
</@footer>
</@pageTheme>